<template>
  <div class="container">
    <div ref="screen" class="screen">
      <Top />
      <div class="bottom">
        <div class="left">
          <Touris class="tourist" />
          <Sex class="sex" />
          <Age class="age" />
        </div>
        <div class="center">
          <Map class="map" />
          <Line class="line" />
        </div>
        <div class="right">
          <Rank class="rank" />
          <Year class="year" />
          <Counter class="counter" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
//顶部组件
import Top from './components/top/index.vue';
//左侧组件
import Touris from './components/tourist/index.vue';
import Sex from './components/sex/index.vue';
import Age from './components/age/index.vue';
//中间组件
import Map from './components/map/index.vue';
import Line from './components/line/index.vue';
//右侧组件
import Rank from './components/rank/index.vue';
import Year from './components/year/index.vue';
import Counter from './components/counter/index.vue';

import { onMounted, ref } from 'vue';
onMounted(() => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`;
});
//数据大屏盒子示例
let screen = ref();
let getScale = (w = 1920, h = 1080) => {
  const ww = window.innerWidth / w;
  const wh = window.innerHeight / h;
  return ww < wh ? ww : wh;
};
window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`;
};
</script>

<style lang="scss" scoped>
.container {
  width: 100vw;
  height: 100vh;
  background: url('../../assets/images/screen/bg.png') no-repeat;
  background-size: cover;
  .screen {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 1920px;
    height: 1080px;
    transform-origin: left top;
    .bottom {
      display: flex;
      .left {
        height: 1040px;
        flex: 1;
        display: flex;
        flex-direction: column;
        .tourist {
          margin: 20px;
          flex: 1.5;
        }
        .sex {
          margin: 0 20px;
          flex: 1;
        }
        .age {
          margin: 20px;
          flex: 1;
        }
      }
      .center {
        flex: 2;
        display: flex;
        flex-direction: column;
        .map {
          flex: 3;
          margin: 70px 0 20px 0;
          box-sizing: border-box;
        }
        .line {
          flex: 1;
        }
      }
      .right {
        flex: 1;
        display: flex;
        flex-direction: column;
        .rank {
          margin: 20px;
          flex: 1.5;
        }
        .year {
          margin: 0 20px;
          flex: 1;
        }
        .counter {
          margin: 20px 20px 0 20px;
          flex: 1;
        }
      }
    }
  }
}
</style>
